/* pipe.h - isbadpipid */

/* Maximum number of pipes in the system */

#ifndef NPIPE
#define	NPIPE		10
#endif	

#ifndef PIPE_SIZ
#define	PIPE_SIZ	256
#endif

/* Pipe state constants */

#define	PIPE_FREE	0	/* pipe table entry is unused	*/
#define	PIPE_USED	1	/* pipe is created with no connected process	*/
#define	PIPE_CONNECTED	2	/* two processes connected to the pipe		*/

/* Inline code to check pipe ID (assumes interrupts are disabled)	*/

#define	isbadpipid(x)	( ((pipid32)(x) < 0) || \
			  ((pipid32)(x) >= NPIPE) || \
			  (piptab[(x)].pistate == PIPE_FREE))

/* Definition of the pipe table (multiple of 32 bits) */

struct pipent {				/* entry in the process table		*/
	uint16	pistate;		/* pipe state: PIPE_FREE, etc.		*/
	char pipebuffer[PIPE_SIZ];	/* buffer of a pipe with size PIPE_SIZ	*/
	sid32 psem;			/* semaphore for producer		*/
	sid32 csem;			/* semaphore for consumer		*/
};

extern	struct	pipent piptab[];
